home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cuj1008.zip / 1008014B < prev    next >
Text File  |  1992-06-12  |  441b  |  22 lines

  1.  
  2. Listing 4 -- getenv.c
  3.  
  4. * getenv function -- in-memory version */
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "yfuns.h"
  8.  
  9. char *(getenv)(const char *name)
  10.     {    /* search environment list for named entry */
  11.     const char *s;
  12.     size_t n = strlen(name);
  13.  
  14.     for (s = _Envp; *s; s += strlen(s) + 1)
  15.         {    /* look for name match */
  16.         if (!strncmp(s, name, n) && s[n] == '=')
  17.             return ((char *)&s[n + 1]);
  18.         }
  19.     return (NULL);
  20.     }
  21.  
  22.